/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eps.modelo.javabeans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author luis
 */
@Entity
@Table(name = "T_Ruta")
@NamedQueries({
    @NamedQuery(name = "Ruta.findAll", query = "SELECT r FROM Ruta r"),
    @NamedQuery(name = "Ruta.findByTRutaID", query = "SELECT r FROM Ruta r WHERE r.tRutaID = :tRutaID"),
    @NamedQuery(name = "Ruta.findByDescripcion", query = "SELECT r FROM Ruta r WHERE r.descripcion = :descripcion")})
public class Ruta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "T_Ruta_ID")
    private Integer tRutaID;
    @Basic(optional = false)
    @Column(name = "descripcion")
    private String descripcion;
    @JoinTable(name = "T_DetalleRutaUsuario", joinColumns = {
        @JoinColumn(name = "T_Ruta_ID", referencedColumnName = "T_Ruta_ID")}, inverseJoinColumns = {
        @JoinColumn(name = "T_Usuario_ID", referencedColumnName = "T_Usuario_ID")})
    @ManyToMany
    private List<Usuario> usuarioList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tRutaID")
    private List<PadronLectura> padronLecturaList;
    @JoinColumn(name = "T_Sector_ID", referencedColumnName = "T_Sector_ID")
    @ManyToOne(optional = false)
    private Sector tSectorID;

    public Ruta() {
    }

    public Ruta(Integer tRutaID) {
        this.tRutaID = tRutaID;
    }

    public Ruta(Integer tRutaID, String descripcion) {
        this.tRutaID = tRutaID;
        this.descripcion = descripcion;
    }

    public Integer getTRutaID() {
        return tRutaID;
    }

    public void setTRutaID(Integer tRutaID) {
        this.tRutaID = tRutaID;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public List<Usuario> getUsuarioList() {
        return usuarioList;
    }

    public void setUsuarioList(List<Usuario> usuarioList) {
        this.usuarioList = usuarioList;
    }

    public List<PadronLectura> getPadronLecturaList() {
        return padronLecturaList;
    }

    public void setPadronLecturaList(List<PadronLectura> padronLecturaList) {
        this.padronLecturaList = padronLecturaList;
    }

    public Sector getTSectorID() {
        return tSectorID;
    }

    public void setTSectorID(Sector tSectorID) {
        this.tSectorID = tSectorID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tRutaID != null ? tRutaID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ruta)) {
            return false;
        }
        Ruta other = (Ruta) object;
        if ((this.tRutaID == null && other.tRutaID != null) || (this.tRutaID != null && !this.tRutaID.equals(other.tRutaID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "murguia.ejb30.entity.COMER.Ruta[tRutaID=" + tRutaID + "]";
    }

}
